<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
 <head>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  <title>Configure the printer connection</title>

 </head>
 <body><div class="manualnavbar" style="text-align: center;">
 <div class="prev" style="text-align: left; float: left;"><a href="function.printer-select-pen.html">printer_select_pen</a></div>
 <div class="next" style="text-align: right; float: right;"><a href="function.printer-start-doc.html">printer_start_doc</a></div>
 <div class="up"><a href="ref.printer.html">Printer 函数</a></div>
 <div class="home"><a href="index.html">PHP Manual</a></div>
</div><hr /><div id="function.printer-set-option" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">printer_set_option</h1>
  <p class="verinfo">(PECL printer SVN)</p><p class="refpurpose"><span class="refname">printer_set_option</span> &mdash; <span class="dc-title">Configure the printer connection</span></p>

 </div>
 
 <div class="refsect1 description" id="refsect1-function.printer-set-option-description">
  <h3 class="title">说明</h3>
  <div class="methodsynopsis dc-description">
   <span class="type">bool</span> <span class="methodname"><strong>printer_set_option</strong></span>
    ( <span class="methodparam"><span class="type">resource</span> <code class="parameter">$printer_handle</code></span>
   , <span class="methodparam"><span class="type">int</span> <code class="parameter">$option</code></span>
   , <span class="methodparam"><span class="type"><a href="language.pseudo-types.html#language.types.mixed" class="type mixed">mixed</a></span> <code class="parameter">$value</code></span>
   )</div>

  <p class="para rdfs-comment">
   The function sets options for the current connection.
  </p>
 </div>


 <div class="refsect1 parameters" id="refsect1-function.printer-set-option-parameters">
  <h3 class="title">参数</h3>
  <p class="para">
   <dl>

    
     <dt>
<em><code class="parameter">printer_handle</code></em></dt>

     <dd>

      <p class="para">
       <em><code class="parameter">printer_handle</code></em> must be a valid printer handle.
      </p>
     </dd>

    
    
     <dt>
<em><code class="parameter">option</code></em></dt>

     <dd>

      <p class="para">
       Option can be one of the following constants:
       <ul class="itemizedlist">
        <li class="listitem">
         <span class="simpara">
          <strong><code>PRINTER_COPIES</code></strong>:
          sets how many copies should be printed, <em><code class="parameter">value</code></em>
          must be an integer.
         </span>
        </li>
        <li class="listitem">
         <span class="simpara">
          <strong><code>PRINTER_MODE</code></strong>:
          specifies the type of data (text, raw or emf),
          <em><code class="parameter">value</code></em> must be a string.
         </span>
        </li>
        <li class="listitem">
         <span class="simpara">
          <strong><code>PRINTER_TITLE</code></strong>:
          specifies the name of the document, <em><code class="parameter">value</code></em>
          must be a string.
         </span>
        </li>
        <li class="listitem">
         <span class="simpara">
          <strong><code>PRINTER_ORIENTATION</code></strong>:
          specifies the orientation of the paper, <em><code class="parameter">value</code></em>
          can be either <strong><code>PRINTER_ORIENTATION_PORTRAIT</code></strong> or
          <strong><code>PRINTER_ORIENTATION_LANDSCAPE</code></strong>
         </span>
        </li>
        <li class="listitem">
         <span class="simpara">
          <strong><code>PRINTER_RESOLUTION_Y</code></strong>:
          specifies the y-resolution in DPI, <em><code class="parameter">value</code></em>
          must be an integer.
         </span>
        </li>
        <li class="listitem">
         <span class="simpara">
          <strong><code>PRINTER_RESOLUTION_X</code></strong>:
          specifies the x-resolution in DPI, <em><code class="parameter">value</code></em>
          must be an integer.
         </span>
        </li>
        <li class="listitem">
         <span class="simpara">
          <strong><code>PRINTER_PAPER_FORMAT</code></strong>:
          specifies a predefined paper format, set <em><code class="parameter">value</code></em>
          to <strong><code>PRINTER_FORMAT_CUSTOM</code></strong> if you want to specify a custom format with
          <strong><code>PRINTER_PAPER_WIDTH</code></strong> and <strong><code>PRINTER_PAPER_LENGTH</code></strong>.
          <em><code class="parameter">value</code></em> can be one of the following constants.
         </span>
         <ul class="itemizedlist">
          <li class="listitem">
           <span class="simpara">
            <strong><code>PRINTER_FORMAT_CUSTOM</code></strong>:
            let&#039;s you specify a custom paper format.
           </span>
          </li>
          <li class="listitem">
           <span class="simpara">
            <strong><code>PRINTER_FORMAT_LETTER</code></strong>:
            specifies standard letter format (8 1/2- by 11-inches).
           </span>
          </li>
          <li class="listitem">
           <span class="simpara">
            <strong><code>PRINTER_FORMAT_LEGAL</code></strong>:
            specifies standard legal format (8 1/2- by 14-inches).
           </span>
          </li>
          <li class="listitem">
           <span class="simpara">
            <strong><code>PRINTER_FORMAT_A3</code></strong>:
            specifies standard A3 format (297- by 420-millimeters).
           </span>
          </li>
          <li class="listitem">
           <span class="simpara">
            <strong><code>PRINTER_FORMAT_A4</code></strong>:
            specifies standard A4 format (210- by 297-millimeters).
           </span>
          </li>
          <li class="listitem">
           <span class="simpara">
            <strong><code>PRINTER_FORMAT_A5</code></strong>:
            specifies standard A5 format (148- by 210-millimeters).
           </span>
          </li>
          <li class="listitem">
           <span class="simpara">
            <strong><code>PRINTER_FORMAT_B4</code></strong>:
            specifies standard B4 format (250- by 354-millimeters).
           </span>
          </li>
          <li class="listitem">
           <span class="simpara">
            <strong><code>PRINTER_FORMAT_B5</code></strong>:
            specifies standard B5 format (182- by 257-millimeter).
           </span>
          </li>
          <li class="listitem">
           <span class="simpara">
            <strong><code>PRINTER_FORMAT_FOLIO</code></strong>:
            specifies standard FOLIO format (8 1/2- by 13-inch).
           </span>
          </li>
         </ul>
        </li>
        <li class="listitem">
         <span class="simpara">
          <strong><code>PRINTER_PAPER_LENGTH</code></strong>:
          if <strong><code>PRINTER_PAPER_FORMAT</code></strong> is set to
          <strong><code>PRINTER_FORMAT_CUSTOM</code></strong>,
          <strong><code>PRINTER_PAPER_LENGTH</code></strong> specifies a custom paper length in mm,
          <em><code class="parameter">value</code></em> must be an integer.
         </span>
        </li>
        <li class="listitem">
         <span class="simpara">
          <strong><code>PRINTER_PAPER_WIDTH</code></strong>:
          if <strong><code>PRINTER_PAPER_FORMAT</code></strong> is set to <strong><code>PRINTER_FORMAT_CUSTOM</code></strong>,
          <strong><code>PRINTER_PAPER_WIDTH</code></strong> specifies a custom paper width in mm,
          <em><code class="parameter">value</code></em> must be an integer.
         </span>
        </li>
        <li class="listitem">
         <span class="simpara">
          <strong><code>PRINTER_SCALE</code></strong>:
          specifies the factor by which the printed output is to be scaled.
          the page size is scaled from the physical page size by a factor
          of scale/100. for example if you set the scale to 50, the output
          would be half of its original size. <em><code class="parameter">value</code></em>
          must be an integer.
         </span>
        </li>
        <li class="listitem">
         <span class="simpara">
          <strong><code>PRINTER_BACKGROUND_COLOR</code></strong>:
          specifies the background color for the actual device context,
          <em><code class="parameter">value</code></em> must be a string containing the rgb
          information in hex format i.e. &quot;005533&quot;.
         </span>
        </li>
        <li class="listitem">
         <span class="simpara">
          <strong><code>PRINTER_TEXT_COLOR</code></strong>:
          specifies the text color for the actual device context,
          <em><code class="parameter">value</code></em> must be a string containing the rgb
          information in hex format i.e. &quot;005533&quot;.
         </span>
        </li>
        <li class="listitem">
         <span class="simpara">
          <strong><code>PRINTER_TEXT_ALIGN</code></strong>:
          specifies the text alignment for the actual device context,
          <em><code class="parameter">value</code></em> can be combined through OR&#039;ing the
          following constants:
         </span>
         <ul class="itemizedlist">
          <li class="listitem">
           <span class="simpara">
            <strong><code>PRINTER_TA_BASELINE</code></strong>:
            text will be aligned at the base line.
           </span>
          </li>
          <li class="listitem">
           <span class="simpara">
            <strong><code>PRINTER_TA_BOTTOM</code></strong>:
            text will be aligned at the bottom.
           </span>
          </li>
          <li class="listitem">
           <span class="simpara">
            <strong><code>PRINTER_TA_TOP</code></strong>:
            text will be aligned at the top.
           </span>
          </li>
          <li class="listitem">
           <span class="simpara">
            <strong><code>PRINTER_TA_CENTER</code></strong>:
            text will be aligned at the center.
           </span>
          </li>
          <li class="listitem">
           <span class="simpara">
            <strong><code>PRINTER_TA_LEFT</code></strong>:
            text will be aligned at the left.
           </span>
          </li>
          <li class="listitem">
           <span class="simpara">
            <strong><code>PRINTER_TA_RIGHT</code></strong>:
            text will be aligned at the right.
           </span>
          </li>
         </ul>
        </li>
       </ul>
      </p>
     </dd>

    
    
     <dt>
<em><code class="parameter">value</code></em></dt>

     <dd>

      <p class="para">
       The <em><code class="parameter">option</code></em> value.
      </p>
     </dd>

    
   </dl>

  </p>
 </div>


 <div class="refsect1 returnvalues" id="refsect1-function.printer-set-option-returnvalues">
  <h3 class="title">返回值</h3>
  <p class="para">
   成功时返回 <strong><code>TRUE</code></strong>， 或者在失败时返回 <strong><code>FALSE</code></strong>。
  </p>
 </div>


 <div class="refsect1 examples" id="refsect1-function.printer-set-option-examples">
  <h3 class="title">范例</h3>
  <p class="para">
   <div class="example" id="example-5262">
    <p><strong>Example #1 <span class="function"><strong>printer_set_option()</strong></span> example</strong></p>
    <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br />$handle&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">printer_open</span><span style="color: #007700">();<br /></span><span style="color: #0000BB">printer_set_option</span><span style="color: #007700">(</span><span style="color: #0000BB">$handle</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">PRINTER_SCALE</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">75</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">printer_set_option</span><span style="color: #007700">(</span><span style="color: #0000BB">$handle</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">PRINTER_TEXT_ALIGN</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">PRINTER_TA_LEFT</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">printer_close</span><span style="color: #007700">(</span><span style="color: #0000BB">$handle</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">?&gt;</span>
</span>
</code></div>
    </div>

   </div>
  </p>
 </div>

  
</div><hr /><div class="manualnavbar" style="text-align: center;">
 <div class="prev" style="text-align: left; float: left;"><a href="function.printer-select-pen.html">printer_select_pen</a></div>
 <div class="next" style="text-align: right; float: right;"><a href="function.printer-start-doc.html">printer_start_doc</a></div>
 <div class="up"><a href="ref.printer.html">Printer 函数</a></div>
 <div class="home"><a href="index.html">PHP Manual</a></div>
</div></body></html>
